import maya.cmds as cmds;
import maya.mel;



cmds.SelectAll();
cmds.Delete();

wallThickness = 4.0;
horizontalBoomFudge = 0.1;
boomWidth = 12.7 + horizontalBoomFudge;# 0 .5 in to mm
height = wallThickness + boomWidth/2.0;# just making it 3 mm to be an even metric number, 
fudge = 0.6;
zipWidth = 5.0;
zipThickness= 1.0;

holeDiameter = 3.7084 + fudge;#6 screw chart width
blockSize = 50;
batteryWidth = 37.0;



def alignAndSubtract(object):
    cmds.select(object[0],borderBlock[0]);
    cmds.align(z='min',alignToLead=True);
    cmds.align(y='min',alignToLead=True);
    cmds.select(object[0]);
    cmds.move(0,wallThickness,0,relative=True);
    cmds.select(borderBlock[0],object[0]);
    return cmds.polyBoolOp(op=2,useThresholds=1);

def removeSides(sign):
    side = cmds.polyCube(w=blockSize, h=boomWidth/2.0 + wallThickness,d=blockSize);
    cmds.move(sign*(blockSize/2.0 + boomWidth/2.0 + wallThickness),0,wallThickness*2+boomWidth,relative=True);
    cmds.select(borderBlock[0],side[0]);
    return cmds.polyBoolOp(op=2,useThresholds=1);

def zipHorizontal(x,y):
    zipBlock = cmds.polyCube(w=zipWidth, h=height,d=zipThickness);
    cmds.select(zipBlock[0],borderBlock[0]);
    cmds.align(z='min',alignToLead=True);
    cmds.select(zipBlock[0]);
    cmds.move(x,0,y,relative=True);
    cmds.select(borderBlock[0],zipBlock[0]);
    return cmds.polyBoolOp(op=2,useThresholds=1);

def zipVertical(x,y):
    zipBlock = cmds.polyCube(w=zipThickness, h=height*2.0,d=zipWidth);
    cmds.select(zipBlock[0],borderBlock[0]);
    cmds.align(z='min',alignToLead=True);
    cmds.select(zipBlock[0]);
    cmds.move(x,0,y,relative=True);
    cmds.select(borderBlock[0],zipBlock[0]);
    return cmds.polyBoolOp(op=2,useThresholds=1);      

   
    

borderBlock = cmds.polyCube(w=blockSize, h=(boomWidth/2.0 + wallThickness)/2.0,d=blockSize*2.0);
pipeBlock = cmds.polyCube(w=boomWidth+wallThickness*2, h=boomWidth/2.0 + wallThickness,d=blockSize*2.0+2.0*boomWidth);

cmds.select(pipeBlock[0],borderBlock[0]);
cmds.align(y='min',alignToLead=True);

cmds.select(borderBlock[0],pipeBlock[0]);
borderBlock = cmds.polyBoolOp(op=1,useThresholds=1); 

verticalBoom = cmds.polyCube(w=boomWidth, h=boomWidth,d=blockSize*2.0+3*boomWidth);
borderBlock = alignAndSubtract(verticalBoom);
 
borderBlock = zipVertical(-boomWidth/2.0-wallThickness,boomWidth/2.0);
borderBlock = zipVertical(boomWidth/2.0+wallThickness,boomWidth/2.0);
 
borderBlock = zipVertical(-boomWidth/2.0-wallThickness,boomWidth*1.5+blockSize*2.0-zipWidth);
borderBlock = zipVertical(boomWidth/2.0+wallThickness,boomWidth*1.5+blockSize*2.0-zipWidth);

zipThickness= 3.0;#changing zipthickness to reuse for velcroholes
zipWidth = 15.0;

borderBlock = zipVertical(-batteryWidth/2.0,boomWidth-zipWidth/2.0 + 0.2*blockSize*2.0);
borderBlock = zipVertical(batteryWidth/2.0,boomWidth-zipWidth/2.0 + 0.2*blockSize*2.0);

borderBlock = zipVertical(-batteryWidth/2.0,boomWidth-zipWidth/2.0 + 0.8*blockSize*2.0);
borderBlock = zipVertical(batteryWidth/2.0,boomWidth-zipWidth/2.0 + 0.8*blockSize*2.0);
cmds.rotate(90,0,0,r=True);

